/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.web.random;

import java.util.Random;

/**
 *
 * @author Usuario
 */
public class Aleatorio {
    
    public String cadenaAleatoria(){
        String cadenaAleatoria = "";
        long milis = new java.util.GregorianCalendar().getTimeInMillis();
        Random r = new Random(milis);
        int i = 0;
        while ( i < 5){
        char c = (char)r.nextInt(255);
        if ( (c >= '0' && c <='9') || (c >='A' && c <='Z') ){
        cadenaAleatoria += c;
        i ++;
        }
        }
        return cadenaAleatoria;
        }
    
    public long idAleatorio(){
        Random r = new Random();
        int ret = (int)r.nextLong();
        if(ret>0){
            return  ret;
        }else{
            idAleatorio();
        }
        return 0;
    }
   
}
